package com.jiazhong.Servlet;

import com.jiazhong.Model.Goods;
import com.jiazhong.Service.GoodsService;
import com.jiazhong.Service.Impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/goods/queryGoods.do")
public class QueryGoodsServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //创建GoodsService接口的实现类对象
        GoodsService goodsService=new GoodsServiceImpl();
        List<Goods> goodsList=goodsService.queryGoods();
        //将goodsList对象存入到request中
        request.setAttribute("goodsList",goodsList);
        request.getRequestDispatcher("/Goods/showGoods.jsp").forward(request,response);
    }
}
